<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title><?php echo ($meta_title); ?>|管理平台</title>
    <link rel="stylesheet" type="text/css" href="/llq/Public/Admin/css/base.css" media="all">
    <link rel="stylesheet" type="text/css" href="/llq/Public/Admin/css/common.css" media="all">
    <link rel="stylesheet" type="text/css" href="/llq/Public/Admin/css/module.css">
    <link rel="stylesheet" type="text/css" href="/llq/Public/Admin/css/style.css" media="all">
	<link rel="stylesheet" type="text/css" href="/llq/Public/Admin/css/<?php echo (C("COLOR_STYLE")); ?>.css" media="all">
     <!--[if lt IE 9]>
    <script type="text/javascript" src="/llq/Public/static/jquery-1.10.2.min.js"></script>
    <![endif]--><!--[if gte IE 9]><!-->
    <script type="text/javascript" src="/llq/Public/static/jquery-2.0.3.min.js"></script>
    <script type="text/javascript" src="/llq/Public/Admin/js/jquery.mousewheel.js"></script>
     <!--<link rel="stylesheet" href="/llq/Public/Admin/css/ace.min.css" id="main-ace-style" />-->
     <!--<link rel="stylesheet" href="/llq/Public/Admin/css/bootstrap.min.css" />-->
    <!--<![endif]-->
    
</head>
<body>
    <!-- 头部 -->
    <div class="header">
        <!-- 主导航 -->
        <ul class="main-nav">
            <li style="width: 200px; color:#fff; font-size: 18px; font-weight: bold; text-align: center; ">
            浏览器后台
            </li>
            <?php if(is_array($__MENU__["main"])): $i = 0; $__LIST__ = $__MENU__["main"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($i % 2 );++$i;?><li class="<?php echo ((isset($menu["class"]) && ($menu["class"] !== ""))?($menu["class"]):''); ?>"><a href="<?php echo (U($menu["url"])); ?>"><?php echo ($menu["title"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
        </ul>
        <!-- /主导航 -->

        <!-- 用户栏 -->
        <div class="user-bar">
            <a href="javascript:;" class="user-entrance"><i class="icon-user"></i></a>
            <ul class="nav-list user-menu hidden">
                <li class="manager">你好，<em title="<?php echo session('user_auth.username');?>"><?php echo session('user_auth.username');?></em></li>
                <li><a href="<?php echo U('User/updatePassword');?>">修改密码</a></li>
                <li><a href="<?php echo U('User/updateNickname');?>">修改昵称</a></li>
                <li><a href="<?php echo U('Public/logout');?>">退出</a></li>
            </ul>
        </div>
    </div>
    <!-- /头部 -->

    <!-- 边栏 -->
    <div class="sidebar">
        <!-- 子导航 -->
        
            <div id="subnav" class="subnav">
                <?php if(!empty($_extra_menu)): ?>
                    <?php echo extra_menu($_extra_menu,$__MENU__); endif; ?>
                <?php if(is_array($__MENU__["child"])): $i = 0; $__LIST__ = $__MENU__["child"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$sub_menu): $mod = ($i % 2 );++$i;?><!-- 子导航 -->
                    <?php if(!empty($sub_menu)): if(!empty($key)): ?><h3><i class="icon icon-unfold"></i><?php echo ($key); ?></h3><?php endif; ?>
                        <ul class="side-sub-menu">
                            <?php if(is_array($sub_menu)): $i = 0; $__LIST__ = $sub_menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($i % 2 );++$i;?><li>
                                    <a class="item" href="<?php echo (U($menu["url"])); ?>"><?php echo ($menu["title"]); ?></a>
                                </li><?php endforeach; endif; else: echo "" ;endif; ?>
                        </ul><?php endif; ?>
                    <!-- /子导航 --><?php endforeach; endif; else: echo "" ;endif; ?>
            </div>
        
        <!-- /子导航 -->
    </div>
    <!-- /边栏 -->

    <!-- 内容区 -->
    <div id="main-content">
        <div id="top-alert" class="fixed alert alert-error" style="display: none;">
            <button class="close fixed" style="margin-top: 4px;">&times;</button>
            <div class="alert-content">这是内容</div>
        </div>
        <div id="main" class="main">
            
            <!-- nav -->
            <?php if(!empty($_show_nav)): ?><div class="breadcrumb">
                <span>您的位置:</span>
                <?php $i = '1'; ?>
                <?php if(is_array($_nav)): foreach($_nav as $k=>$v): if($i == count($_nav)): ?><span><?php echo ($v); ?></span>
                    <?php else: ?>
                    <span><a href="<?php echo ($k); ?>"><?php echo ($v); ?></a>&gt;</span><?php endif; ?>
                    <?php $i = $i+1; endforeach; endif; ?>
            </div><?php endif; ?>
            <!-- nav -->
            

            
    <link rel="stylesheet" type="text/css" href="/llq/Public/Admin/css/index.css">
    <link rel="stylesheet" type="text/css" href="/llq/Public/Admin/css/upload.css">
    <script type="text/javascript" src="/llq/Public/static/uploadify/jquery.uploadify.min.js"></script>

    <div class="main-title">
        <h2><?php echo ($meta_title); ?></h2>
    </div>
    <form action="" method="post" class="form-horizontal">
        <input type="hidden" name="id" id="id" value="<?php echo ($data['id']); ?>">
        
        <div class="form-item">
            <label class="item-label">广告图</label>
            <div class="controls">

                <div class="img-box full">
                    <section class=" img-section">
                        <!--<p class="up-p">作品图片：<span class="up-span">最多可以上传5张图片，马上上传</span></p>-->
                        <div class="z_photo upimg-div clear" >
                            <?php if(!empty($data)):?>
                            <section class="up-section fl">
                                     <span class="up-span"></span>
                                     <img src="/llq/Public/Admin/images/a7.png" class="close-upimg">
                                     <img src="/llq<?php echo ($data['img_url']); ?>" class="up-img">
                                 <p class="img-namep"></p>
                                 <input id="taglocation" name="taglocation" value="" type="hidden">
                                 <input id="tags" name="tags" value="" type="hidden">
                             </section>
                            <?php endif;?>
                            <section class="z_file fl" style="<?php if(!empty($data)){echo "display: none;";}?>">
                                
                                <img src="/llq/Public/Admin/images/a11.png" class="add-img">
                               
                                <input type='hidden' name='img_url' value="<?php echo ($data['img_url']); ?>" class='img-url js-pic_url' >
                                <input type="file" name="file" id="file" class="file" value="" accept="image/jpg,image/jpeg,image/png,image/bmp" multiple />
                            </section>
                        </div>
                    </section>
                </div>
                <aside class="mask works-mask">
                    <div class="mask-content">
                        <p class="del-p">您确定要删除图片吗？</p>
                        <p class="check-p"><span class="del-com wsdel-ok">确定</span><span class="wsdel-no">取消</span></p>
                    </div>
                </aside>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">网址</label>
            <div class="controls">
                <input type="text" class="text input-large" name="jump_url" value="<?php echo ($data['jump_url']); ?>" placeholder="http://">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">排序(数字越小，越靠前)</label>
            <div class="controls">
                <input type="text" class="text input-large" name="sort" value="<?php echo ($data['sort']); ?>" placeholder="默认99，排序值越小越靠前">
            </div>
        </div>
        <div class="form-item">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">提交</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>

        </div>
        <div class="cont-ft">
            <div class="copyright">
                <div class="fl">感谢使用 管理平台</div>
            </div>
        </div>
    </div>
    <!-- /内容区 -->
    <script type="text/javascript">
    (function(){
        var ThinkPHP = window.Think = {
            "ROOT"   : "/llq", //当前网站地址
            "APP"    : "/llq/admin.php?s=", //当前项目地址
            "PUBLIC" : "/llq/Public", //项目公共目录地址
            "DEEP"   : "<?php echo C('URL_PATHINFO_DEPR');?>", //PATHINFO分割符
            "MODEL"  : ["<?php echo C('URL_MODEL');?>", "<?php echo C('URL_CASE_INSENSITIVE');?>", "<?php echo C('URL_HTML_SUFFIX');?>"],
            "VAR"    : ["<?php echo C('VAR_MODULE');?>", "<?php echo C('VAR_CONTROLLER');?>", "<?php echo C('VAR_ACTION');?>"]
        }
    })();
    </script>
    <script type="text/javascript" src="/llq/Public/static/think.js"></script>
    <script type="text/javascript" src="/llq/Public/Admin/js/common.js"></script>
    <script type="text/javascript">
        +function(){
            var $window = $(window), $subnav = $("#subnav"), url;
            $window.resize(function(){
                $("#main").css("min-height", $window.height() - 130);
            }).resize();

            /* 左边菜单高亮 */
            url = window.location.pathname + window.location.search;
            url = url.replace(/(\/(p)\/\d+)|(&p=\d+)|(\/(id)\/\d+)|(&id=\d+)|(\/(group)\/\d+)|(&group=\d+)/, "");
            $subnav.find("a[href='" + url + "']").parent().addClass("current");

            /* 左边菜单显示收起 */
            $("#subnav").on("click", "h3", function(){
                var $this = $(this);
                $this.find(".icon").toggleClass("icon-fold");
                $this.next().slideToggle("fast").siblings(".side-sub-menu:visible").
                      prev("h3").find("i").addClass("icon-fold").end().end().hide();
            });

            $("#subnav h3 a").click(function(e){e.stopPropagation()});

            /* 头部管理员菜单 */
            $(".user-bar").mouseenter(function(){
                var userMenu = $(this).children(".user-menu ");
                userMenu.removeClass("hidden");
                clearTimeout(userMenu.data("timeout"));
            }).mouseleave(function(){
                var userMenu = $(this).children(".user-menu");
                userMenu.data("timeout") && clearTimeout(userMenu.data("timeout"));
                userMenu.data("timeout", setTimeout(function(){userMenu.addClass("hidden")}, 100));
            });

	        /* 表单获取焦点变色 */
	        $("form").on("focus", "input", function(){
		        $(this).addClass('focus');
	        }).on("blur","input",function(){
				        $(this).removeClass('focus');
			        });
		    $("form").on("focus", "textarea", function(){
			    $(this).closest('label').addClass('focus');
		    }).on("blur","textarea",function(){
			    $(this).closest('label').removeClass('focus');
		    });

            // 导航栏超出窗口高度后的模拟滚动条
            var sHeight = $(".sidebar").height();
            var subHeight  = $(".subnav").height();
            var diff = subHeight - sHeight; //250
            var sub = $(".subnav");
            if(diff > 0){
                $(window).mousewheel(function(event, delta){
                    if(delta>0){
                        if(parseInt(sub.css('marginTop'))>-10){
                            sub.css('marginTop','0px');
                        }else{
                            sub.css('marginTop','+='+10);
                        }
                    }else{
                        if(parseInt(sub.css('marginTop'))<'-'+(diff-10)){
                            sub.css('marginTop','-'+(diff-10));
                        }else{
                            sub.css('marginTop','-='+10);
                        }
                    }
                });
            }
        }();
    </script>
    
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('<?php echo U('Guanggao / index');?>');
    </script>

    <script type="text/javascript">
        $(function () {
            var maxupload = 1;
            var delParent;
            var defaults = {
                fileType: ["jpg", "png", "bmp", "jpeg"], // 上传文件的类型
                fileSize: 1024 * 1024 * 10                  // 上传文件的大小 10M
            };
            /*点击图片的文本框*/
            $(".file").change(function () {
                var idFile = $(this).attr("id");
                var file = document.getElementById(idFile);

                var imgContainer = $(this).parents(".z_photo"); //存放图片的父亲元素
                var fileList = file.files; //获取的图片文件

                var input = $(this).parent();//文本框的父亲元素
                var imgArr = [];
                //遍历得到的图片文件
                var numUp = imgContainer.find(".up-section").length;
                var totalNum = numUp + fileList.length;  //总的数量
                if (fileList.length > maxupload || totalNum > maxupload) {
                    alert("上传图片数目不可以超过" + maxupload + "个，请重新选择");  //一次选择上传超过5个 或者是已经上传和这次上传的到的总数也不可以超过5个
                } else if (numUp < maxupload) {

                    fileList = validateUp(fileList);
                    for (var i = 0; i < fileList.length; i++) {
                        var filedata = fileList[i];
                        console.log(filedata);
                        var imgUrl = window.URL.createObjectURL(fileList[i]);
                        imgArr.push(imgUrl);
                        var $section = $("<section class='up-section fl loading'>");
                        imgContainer.prepend($section);
                        var $span = $("<span class='up-span'>");
                        $span.appendTo($section);

                        var $img0 = $("<img class='close-upimg'>").on("click", function (event) {
                            event.preventDefault();
                            event.stopPropagation();
                            $(".works-mask").show();
                            delParent = $(this).parent();
                        });
                        $img0.attr("src", "/llq/Public/Admin/images/a7.png").appendTo($section);
                        var $img = $("<img class='up-img up-opcity'>");
                        $img.attr("src", imgArr[i]);
                        $img.appendTo($section);

                        var formData = new FormData();
                        formData.append("download", filedata);
                        $.ajax({
                            url: "<?php echo U('File/uploadImage');?>",
                            type: "POST",
                            data: formData,
                            /**
                             *必须false才会自动加上正确的Content-Type
                             */
                            contentType: false,
                            /**
                             * 必须false才会避开jQuery对 formdata 的默认处理
                             * XMLHttpRequest会对 formdata 进行正确的处理
                             */
                            processData: false,
                            success: function (data) {
                                $('.js-pic_url').val(data.path);

                            },
                            error: function () {
                                alert("上传失败！");
//                                $("#imgWait").hide();
                            }
                        });
                        var $p = $("<p class='img-name-p'>");
                        $p.html(fileList[i].name).appendTo($section);
                        var $input = $("<input id='taglocation' name='taglocation' value='' type='hidden'>");
                        $input.appendTo($section);
                        var $input2 = $("<input id='tags' name='tags' value='' type='hidden'/>");
                        $input2.appendTo($section);

                    }
                }
                setTimeout(function () {
                    $(".up-section").removeClass("loading");
                    $(".up-img").removeClass("up-opcity");
                }, 450);
                numUp = imgContainer.find(".up-section").length;
                if (numUp >= maxupload) {
                    $(this).parent().hide();
                }

                //input内容清空
                $(this).val("");
            });



            $(".z_photo").delegate(".close-upimg", "click", function () {
                $(".works-mask").show();
                delParent = $(this).parent();
            });

            $(".wsdel-ok").click(function () {
                $(".works-mask").hide();
                var numUp = delParent.siblings().length;
                if (numUp < maxupload + 1) {
                    delParent.parent().find(".z_file").show();
                }
                delParent.remove();

            });

            $(".wsdel-no").click(function () {
                $(".works-mask").hide();
            });

            function validateUp(files) {
                var arrFiles = [];//替换的文件数组
                for (var i = 0, file; file = files[i]; i++) {
                    //获取文件上传的后缀名
                    var newStr = file.name.split("").reverse().join("");
                    if (newStr.split(".")[0] != null) {
                        var type = newStr.split(".")[0].split("").reverse().join("");
                        console.log(type + "===type===");
                        if (jQuery.inArray(type, defaults.fileType) > -1) {
                            // 类型符合，可以上传
                            if (file.size >= defaults.fileSize) {
                                alert(file.size);
                                alert('您这个"' + file.name + '"文件大小过大');
                            } else {
                                // 在这里需要判断当前所有文件中
                                arrFiles.push(file);
                            }
                        } else {
                            alert('您这个"' + file.name + '"上传类型不符合');
                        }
                    } else {
                        alert('您这个"' + file.name + '"没有类型, 无法识别');
                    }
                }
                return arrFiles;
            }

        });
    </script>

</body>
</html>